﻿using System;
using System.Collections.Generic;

namespace Eneta.Portal.Common.Dto
{
    /// <summary>
    /// Class for user profiles.
    /// </summary>
    [Serializable]
    public class UserProfileDto : BaseDto
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="UserProfileDto"/> class.
        /// </summary>
        public UserProfileDto()
        {
            Interests = new List<string>();
        }

        /// <summary>
        /// Gets or sets the about me.
        /// </summary>
        public string AboutMe { get; set; }

        /// <summary>
        /// Gets or sets the address.
        /// </summary>
        public string Address { get; set; }

        /// <summary>
        /// Gets or sets the blog.
        /// </summary>
        public string Blog { get; set; }

        /// <summary>
        /// Gets or sets the company.
        /// </summary>
        public string Company { get; set; }

        /// <summary>
        /// Gets or sets the email.
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// Gets or sets the field of study.
        /// </summary>
        public string FieldOfStudy { get; set; }

        /// <summary>
        /// Gets or sets the first name.
        /// </summary>
        public string FirstName { get; set; }

        /// <summary>
        /// Gets or sets the list of interests.
        /// </summary>
        public IList<string> Interests { get; set; }

        /// <summary>
        /// Gets or sets the job title.
        /// </summary>
        public string JobTitle { get; set; }
        
        /// <summary>
        /// Gets or sets the last name.
        /// </summary>
        public string LastName { get; set; }

        /// <summary>
        /// Gets or sets the live id token of user profile.
        /// </summary>
        public string LiveIdToken { get; internal set; }

        /// <summary>
        /// Gets or sets if user profile is locked by administrator.
        /// </summary>
        public bool Locked { get; set; }

        /// <summary>
        /// Gets or sets the phone.
        /// </summary>
        public string Phone { get; set; }

        public DateTime? ProfileCompletelyFilledDate { get; set; }

        /// <summary>
        /// Gets or sets the school.
        /// </summary>
        public string School { get; set; }

        /// <summary>
        /// Gets or sets the user name of the user.
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to show address.
        /// </summary>
        public bool ShowAddress { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to show company.
        /// </summary>
        /// <value><c>true</c> if [show company]; otherwise, <c>false</c>.</value>
        public bool ShowCompany { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether e-mail address is public.
        /// </summary>
        /// <value><c>true</c> if e-mail address is public; otherwise, <c>false</c>.</value>
        public bool ShowEmail { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to show field of study.
        /// </summary>
        /// <value><c>true</c> if [show field of study]; otherwise, <c>false</c>.</value>
        public bool ShowFieldOfStudy { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether first name is public.
        /// </summary>
        /// <value><c>true</c> if first name is public; otherwise, <c>false</c>.</value>
        public bool ShowFirstName { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to show job title.
        /// </summary>
        /// <value><c>true</c> if [show job title]; otherwise, <c>false</c>.</value>
        public bool ShowJobTitle { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether last name is public.
        /// </summary>
        /// <value><c>true</c> if last name is public; otherwise, <c>false</c>.</value>
        public bool ShowLastName { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to show phone.
        /// </summary>
        /// <value><c>true</c> if [show phone]; otherwise, <c>false</c>.</value>
        public bool ShowPhone { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to show school.
        /// </summary>
        /// <value><c>true</c> if [show school]; otherwise, <c>false</c>.</value>
        public bool ShowSchool { get; set; }

        public bool SendEventsInfo { get; set; }

        public bool SendMsInfo { get; set; }

        public string UserImage32x32Url { get; set; }

        public string UserImage48x48Url { get; set; }

        public string UserImage64x64Url { get; set; }

        /// <summary>
        /// Gets a value indicating whether e-mail block has to be shown to users.
        /// </summary>
        public bool IsEmailVisible
        {
            get
            {
                return ShowEmail && !string.IsNullOrEmpty(Email);
            }
        }

        public int GetProfileFillmentPercent()
        {
            var indicatorValue = 0;

            if (!string.IsNullOrEmpty(FirstName))
                indicatorValue += 5;
            if (!string.IsNullOrEmpty(LastName))
                indicatorValue += 5;
            if (Interests.Count > 0)
                indicatorValue += 5;
            if (!string.IsNullOrEmpty(Email))
                indicatorValue += 5;

            if (!string.IsNullOrEmpty(AboutMe))
                indicatorValue += 20;
            if (!string.IsNullOrEmpty(Blog) || !string.IsNullOrEmpty(Address))
                indicatorValue += 20;
            if (!string.IsNullOrEmpty(UserImage32x32Url))
                indicatorValue += 20;
            if (!string.IsNullOrEmpty(School) || !string.IsNullOrEmpty(Company))
                indicatorValue += 20;

            return indicatorValue;
        }
    }
}
